/*
 * @lc app=leetcode.cn id=621 lang=java
 *
 * [621] 任务调度器
 */

// @lc code=start
class Solution {
    public int leastInterval(char[] tasks, int n) {
        int timeElapse = 0;

        char pre='0';
        for(char task : tasks){
            if(task != pre){
                timeElapse += 1;
            }else{
                timeElapse += n+1;
            }
            pre = task;
        }
        return timeElapse;
    }
}
// @lc code=end

